/**
 * Created by user on 2015/12/3.
 */

var themeService = require('../../../services/mis/operate/themeService');
var messageUtil = require('../../../common/utils/messageUtil');
var toolUtil = require('../../../common/utils/toolUtil');


exports.themeList = function(req, res) {

    themeService.themeListService(req, function(err, results) {

        if (err) {
            logger.error('Exception happen when themeList...' + err.message);
            res.json(messageUtil.composeFailedMessage(req, 'Exception happen when themeList...'));
        }else {
            var data = {
                count:results[0]["count"],
                totalPage: results[0]["totalPage"],
                list: results[1]
            };
            res.json(messageUtil.composeSucceededMessage(req, null, data));
        }

    });

};


exports.themeAdd = function (req, res) {

    themeService.themeAddService(req, function (err, result) {
        if (err) {
            logger.error('Exception happened when addPrize ...!' + err.message);
            res.json(messageUtil.composeFailedMessage(req, err.message));
        } else {
            res.json(messageUtil.composeSucceededMessage(req, null, result));
        }
    });

};


exports.themeDelete = function (req, res) {


};

exports.themeEdit = function (req, res) {

    //logger.debug(req.body);

    themeService.themeEditService(req, function (err, result) {
        if (err) {
            logger.error('Exception happened when themeEdit ...!' + err.message);
            res.json(messageUtil.composeFailedMessage(req, err.message));
        } else {
            res.json(messageUtil.composeSucceededMessage(req, null, result));
        }
    });
};
